﻿<?php
	include 'inc/conn.php';
	include 'sendmail.php';
	extract($_POST);
	extract($_GET);
	unset($_POST,$_GET);

	if (!isset($uid))
	{
		echo "<script>alert('UID is empty!');</script>";
		die("UID is empty!");
	}
	$db = new mysql();
	$sql = "select * from eng_version_control_table where uid=".$uid;
	$db->query($sql);
	$num = $db->db_num_rows();
	if ($num == 0)
		die("No data was found!");
	$row = $db->fetch_assoc();

	if (isset($act))
	{
		if ($act=="go")
		{
			$table = "eng_version_control_table";
			$condition = "UID=${uid}";
			
			if($row['Q_result']==1){
				echo "<script>alert('测试流程已经结束!');</script>";
				die("测试流程已经结束!");
			}
			
			if(strlen($qop)<2)
			{
				echo "<script>alert('检验员没有填写或长度不对!');</script>";
				die("检验员没有填写或长度不对!!");
			}
			
			if (strlen($vContent)>2){
				if(htmlspecialchars_decode($row['REMARK'])=="N/A")
					$acontent=htmlspecialchars("品保：</br>".$vContent);
				else
					$acontent=htmlspecialchars("品保：</br>".$vContent."</br>++++++++++++++++++++++++++++++</br>").$row['REMARK'];
			}else{
				$acontent=$row['REMARK'];
			}
			
			date_default_timezone_set('Asia/Shanghai');
			$dt = date("Y-m-d H:i:s");
			
			$mod_content="`Q_result`=${qresult}, `Q_op`='${qop}', `REMARK`='${acontent}', `Q_check_date`='${dt}'";
			$db->update($table, $mod_content, $condition);
			//////////////////for mail part////////////////////
			$modelname=$row['Model_name'];
			$customername=$row['Customer'];
			$bios=$row['BIOS_version'];
			$ec=$row['EC_version'];
			$image=$row['System_type'];
			$vremark=htmlspecialchars_decode($acontent);
			if($qresult==1)
				$result="<font color='green'>Pass</font>";
			else
				$result="<font color='red'>Fail</font>";
			$vContent="<b>机种：</b>${modelname}</br>
						<b>客户：</b>${customername}</br>
						<b>BIOS：</b>${bios}</br>
						<b>EC：</b>${ec}</br>
						<b>IMAGE：</b>${image}</br>
						<strong>QA验证结果${result}</strong></br>
						<b>备注：</b>${vremark}";
			//SendMail($customername." BIOS/EC/IMAGE 验证结果", $vContent, "QA");
			$param = array(
				'aSync'=>'Yes',
				'title'=>"$customername BIOS/EC/IMAGE 验证结果",
				'msg'=>$vContent,
				'to'=>'QA'
			);
			doAsyncMail($param);		

			echo "<script>alert('提交成功!');window.location='versionlist.php';</script>";
			//////////////////mail end///////////////////
			unset($qresult);
			unset($qop);
		}
	}
	
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">-->
<link rel="stylesheet" href="/css/bootstrap.min.css">
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery-migrate.min.js"></script>
<script type="text/javascript" src="/xhEditor/xheditor.min.js"></script>
<script type="text/javascript" src="/xhEditor/xheditor_lang/zh-cn.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<? echo "<title>确认".htmlspecialchars_decode($row['Customer'])."BIOS/EC/IMAGE测试结果</title>" ; ?>
</head>
<body class="background">
<div class="container white-background pagecontent">
<div class="panel panel-primary">
    <div class="panel-heading">
        <h3 class="panel-title">
		<? echo "查看".htmlspecialchars_decode($row['Customer'])." 详细信息"; ?> 
		</h3>
    </div>
    <div class="panel-body">
	<div class="input-group">
		<span class="input-group-addon">机种名称:</span>
		<input name="modelname" type="text" value="<? echo htmlspecialchars_decode($row['Model_name']); ?>" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">客户名称:</span>
		<input name="customername" type="text" value="<? echo htmlspecialchars_decode($row['Customer']); ?>" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">出货系统:</span>
		<input name="systemver" type="text" value="<? echo htmlspecialchars_decode($row['System_type']); ?>" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">BIOS版本:</span>
		<input name="biosversion" type="text" value="<? echo htmlspecialchars_decode($row['BIOS_version']); ?>" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">BIOS日期:</span>
		<input name="biosdate" type="text" value="<? echo htmlspecialchars_decode($row['Bios_release_date']); ?>" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">EC  版本:</span>
		<input name="ecversion" type="text" value="<? echo htmlspecialchars_decode($row['EC_version']); ?>" class="form-control">
	</div>
	<div class="input-group">
		<span class="input-group-addon">管控人员:
		</span><input name="vowner" type="text" value="<? echo htmlspecialchars_decode($row['Owner']); ?>" class="form-control">
</div>
<?
	echo "<form action='qa_cfm.php?act=go&uid=$uid' method='post'>";
?>
<div><h4><font color='blue'>品保测试结果:</font></h4></div>
<strong>结果:</strong>
<select name="qresult" id="result">
	<option value="1">PASS</option>
	<option value="0">FAIL</option>
</select>
<strong>测试人员:</strong><input name="qop" type="text">
</br>
<div>
<strong>备注：</strong>
<textarea name="vContent" rows="12" cols="80" class="xheditor {tools:'mini',skin:'default', upImgUrl:'upload.php?immediate=1'}" style="width:340px;height:100px;">
</textarea>
</div>
<div><input class="btn btn-success btn-primary" name="submit" value="提交" type="submit"><input class="btn btn-danger" name="reset" value="重写" type="reset"></div>
</form>
<?
	echo "</div>";
	echo "</div>";
	echo "</div>";
	include 'bottom.php';
	echo "</body>";
	echo "</html>";
	$db->close();
?>
